part of '../repository.dart';

class _WebPurchasedItemDtoFactory {
  const _WebPurchasedItemDtoFactory._internal();

  static const _instance = _WebPurchasedItemDtoFactory._internal();

  factory _WebPurchasedItemDtoFactory() {
    return _instance;
  }

  _WebPurchasedItemDto fromJson(Map<String, dynamic> json) {
    final type = json[_kWebPurchasedItemTypeKey] as String;

    if (type == _kWebPurchasedSubscriptionTypeValue) {
      return _WebPurchasedSubscriptionDto.fromJson(json);
    }

    if (type == _kWebOneTimePurchasedItemTypeValue) {
      return _WebOneTimePurchasedItemDto.fromJson(json);
    }

    throw UnimplementedError();
  }
}
